﻿using System;
using AgencyEntityLib.BaseEntity;
using Ecopsy.DataTier;
using System.Collections.Generic;
using FormControllers;
using Ecopsy.Tools;
using System.Windows.Forms;
using System.Web;
using AgencyEntityLib.Context;
using System.Text.RegularExpressions;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       // Response.Redirect("Default2.aspx");
        //Response.Redirect("AppFrame.aspx");

        //Response.Cache.SetCacheability(HttpCacheability.NoCache);

        //ctlSideShedule1.Contract = Contract;
     
        //if (!IsPostBack)
        //            SetSideList();

        
    }

    private void SetSideList()
    {

        //ctlSideShedule1.DtStart = Contract.StartDate;
        //ctlSideShedule1.DtEnd = Contract.EndDate;
        //ctlSideShedule1.DetailsPeriod = DateTimeTools.TimePeriod.Month;
        //ctlSideShedule1.DataBind();        
 
    }

    


    protected Constraction Constraction
    {
        get
        {
            wsConstractions ws = (wsConstractions)GlobalConstants.CurrentAgency.WS_FactoryList[WS_FactoryList.wsKey_Constraction];
            string id = "4ff833b4-4020-4980-8539-146206a2ef57";
            Constraction c = ws.GetConstraction(id);
            return c;
        }


    }

    protected Contract Contract
    {
        get
        {
            wsContract ws = (wsContract)GlobalConstants.CurrentAgency.WS_FactoryList[WS_FactoryList.wsKey_Contract];
            string id = "107082ac-814b-4b0c-9c1c-7fbf20939dea";
            Contract  c = ws.GetContract (id);
            return c;
        }


    }

    private void SetTree()
    { 
        //PropertyTreeView._TreeDictionaryItemSource = iPageController.TreeDictionaryContext.GetAdressProgramm;   
        //PropertyTreeView.TreeDictionaryItemValue = Constraction.AdressProgramm ;
        //PropertyTreeView.TreeCheckBoxType = Samples.CheckBoxType.RadioButton;
        //PropertyTreeView.NodeClass = "TreeNode";
        //PropertyTreeView.DataBind();
    }

    private Int32 ConvertToInt(string s)
    {
        Int32 res=0;  
        foreach (char i in s.ToCharArray() )
        {
            res = res + (int)i;

        }
        return res;

    }

    private void LoadConstraction()
    {

        

        wsConstractions ws = (wsConstractions)GlobalConstants.CurrentAgency.WS_FactoryList[WS_FactoryList.wsKey_Constraction];
        string id = "55c35004-dd14-4d55-9ca8-5666b6d52fc9";
        Constraction c = ws.GetConstraction(id);

        object v = c.ConstractionType;
        string s=c.ConstractionType.GetValueAsString();


        
        TreeDictionaryItem r1 = iPageController.TreeDictionaryContext.GetConstractionType();

        TreeDictionaryItemValue f = r1.BuildValue("62707a0e-4a4d-43b9-bc8e-e53778c1fad6"); // указатель
        TreeDictionaryItemValue f1 = r1.BuildValue("68abb3ec-f979-4553-871a-17317820906c"); // лавочка

        c.ConstractionType.AddValue(f);
        c.ConstractionType.AddValue(f1);


        ws.SaveConstraction(c);
        string ff = c.ConstractionType.GetValueAsString ();

        c.ConstractionType.RemoveValue("62707a0e-4a4d-43b9-bc8e-e53778c1fad6");
        ff = c.ConstractionType.GetValueAsString();

        
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        //PropertyTreeView._TreeDictionaryItemSource = iPageController.TreeDictionaryContext.GetAdressProgramm;   
        //TreeDictionaryItemValue  d = PropertyTreeView.TreeDictionaryItemValue;
        //string s = d.GetValueAsString();
        //Label1.Text = s;

        //Constraction.AdressProgramm = d;
        //Constraction.Save();

    }
    protected void Button3_Click(object sender, EventArgs e)
    {

    }
    protected void Button3_Click1(object sender, EventArgs e)
    {        
        ConstractionList list = new ConstractionList();       

        list.SqlStatment = new ConstractionList.sqlLoadStatment() { Lexeme = "9_15,6_3 Жигули" };
        list.Load();
        GridView1.DataSource = list;
        GridView1.DataBind();
        
    }
    

    
}
